home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / src / Fl_Menu_Bar.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-19  |  1.8 KB  |  64 lines

  1. //
  2. // "$Id: Fl_Menu_Bar.cxx,v 1.7 1999/01/19 19:05:39 mike Exp $"
  3. //
  4. // Menu bar widget for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. #include <FL/Fl.H>
  27. #include <FL/Fl_Menu_Bar.H>
  28.  
  29. void Fl_Menu_Bar::draw() {
  30.   draw_box();
  31.   if (!menu() || !menu()->text) return;
  32.   const Fl_Menu_Item* m;
  33.   int X = x()+6;
  34.   for (m=menu(); m->text; m = m->next()) {
  35.     m->draw(X, y(), 0, h(), this);
  36.     X += m->measure(0,this) + 16;
  37.   }
  38. }
  39.  
  40. int Fl_Menu_Bar::handle(int event) {
  41.   const Fl_Menu_Item* v;
  42.   if (menu() && menu()->text) switch (event) {
  43.   case FL_ENTER:
  44.   case FL_LEAVE:
  45.     return 1;
  46.   case FL_PUSH:
  47.     v = 0;
  48.   J1:
  49.     v = menu()->pulldown(x(), y(), w(), h(), v, this, 0, 1);
  50.     picked(v);
  51.     return 1;
  52.   case FL_SHORTCUT:
  53.     v = menu()->test_shortcut();
  54.     if (v) {picked(v); return 1;}
  55.     if (visible_r() && (v = menu()->find_shortcut())) goto J1;
  56.     return 0;
  57.   }
  58.   return 0;
  59. }
  60.  
  61. //
  62. // End of "$Id: Fl_Menu_Bar.cxx,v 1.7 1999/01/19 19:05:39 mike Exp $".
  63. //
  64.